<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>电影票报表</title>
<link href='../img/base.css' rel='stylesheet' type='text/css'>
<script language="javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.PrintArea.js"></script>
<script language="javascript">
function chkform(){
	var begin_date = $("#begin_date").val();
	var end_date = $("#end_date").val();	
	if( begin_date=="" || end_date=="" )
	{
		alert("请选择交易的起止日期");
		return false;
	}	
	return true;
}
function search_data(){
	if( !chkform() ) return false;	
    $("#result").hide();
    $("#warning_box").show()
	$("#warning_box").empty().append('加载中，请稍候...');
        $.post(
         "report_act.php",
         {
          cinema_id:$("#cinema_id").val(),
          api_user:$("#api_user").val(),
          begin_date:$("#begin_date").val(),
          op:'search',
          end_date:$("#end_date").val()
         },
         function(callback){
                $("#result").hide();
                $("#warning_box").show()
                if(callback == 1){                    
                     $("#warning_box").empty().append('不能跨月查询！')
                }
                else if(callback == 2){                     
                     $("#warning_box").empty().append('查询的时间有误,请输入正确的时间段！')
                }
               else if(callback == 3){                     
                     $("#warning_box").empty().append('抱歉,暂时没有该月的数据报表！')
                }
                else{
                        $("#warning_box").hide()
                        $("#result").show();                                             
                        $(".start_data").empty().html($("#begin_date").val())
                        $(".end_data").empty().html($("#end_date").val())
                        $("#ajax_data_box").empty().append(callback);
                        $("#now_time").empty().append(" <{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}>");                      
                }
         },
         'html'
        )	
}
function export_data(){
	if( !chkform() ) return false;
        window.location= "report_act.php?cinema_id="+$("#cinema_id").val()+"&api_user="+$("#api_user").val()+"&begin_date="+$("#begin_date").val()+"&op=export&end_date="+$("#end_date").val();
       
}
function print_data(){
	$("#result").printArea();
	return false;
}

</script>
</head>

<body leftmargin='8' topmargin='8'>
        <table width="98%" class="condition_table" border="0" style="height: 30px;line-height: 30px;" cellpadding="3" cellspacing="1" bgcolor="#ccd9b9" align="center">	
                <tr>
                        <td height="28"  background='../img/tbg.gif'>
                                <table width="100%" border="0"  cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="50">&nbsp;</td>      
                                          <td width="80">电影院：</td>
                                          <td width="350">
                                                  <select name="cinema_id" id="cinema_id">
                                                        <option value="">所有影院</option>
                                                        <{foreach from=$cinema_list item=cinema_info}>
                                                              <option value="<{$cinema_info.cinema_id}>"><{$cinema_info.cinema_name}></option>
                                                        <{/foreach}>
                                                  </select>
                                          </td>
                                          <td width="80">订票日期：</td>
                                          <td><input type="text" id="begin_date" name="begin_date" value="<{$begin_date}>" onClick="WdatePicker()" /> - <input type="text" id="end_date" name="end_date" value="<{$end_date}>" onClick="WdatePicker()" /><span style="color:red; ">&nbsp;（注意：查询起始时间是同一月份的数据）</span></td>
                                          
                                        </tr>
                                        <tr>
                                                <td>&nbsp;</td>
                                                <td>接入帐号：</td>
                                                <td>
                                                       <select name="api_user" id="api_user">
                                                                <option value="">接入帐号</option>
                                                                <{foreach from=$api_user_list item=api_user_info}>
                                                                      <option value="<{$api_user_info.api_user}>" ><{$api_user_info.api_user}></option>
                                                                <{/foreach}>
                                                       </select>
                                                </td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>                                                
                                        </tr>                                      
                            </table>
                    </td>
                </tr>
	        <tr>
                     <td height="28">
                             <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td align="center">                                                      
                                                   <input type="submit" value="搜索" onClick="return search_data()" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="导出" onClick="return export_data()" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="打印" onClick="return print_data()" />
                                            </td>
                                        </tr>
                             </table>
                     </td>
                </tr>
</table>   
  <table width="98%"  border="0" style="height: 30px;line-height: 30px;" cellpadding="3" cellspacing="1" >	
          <tr>
                  <td>&nbsp;&nbsp;</td>
                  <td style="text-align: right;">打印时间：<span id="now_time"></span></td>
          </tr>
  </table>
                                           
<div id="warning_box" style="text-align: center;line-height: 100px;color:red;"></div>
<div id='result' style="display: none;">   
        <div style="margin: 50px 0px;">
                <div style="font-size: 16px; font-weight: bold;text-align: center;">购票单息信表</div>
                <div style="font-size: 12px; text-align: center;">从 <span class="start_data"></span> 到 <span class="end_data"></span></div>
        </div>        
        <div id="ajax_data_box"></div>
       
</div>
</body>
</html>